import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    token: localStorage.getItem("token"),
    userInfo: JSON.parse(localStorage.getItem("userInfo")) || {}
  },
  mutations: {
  },
  actions: {
    setToken(state,token) {
      localStorage.setItem("token",token)
      state.token = token
    },
    setUserInfo(state,obj) {
      localStorage.setItem("userInfo",JSON.stringify(obj))
      state.userInfo = obj
    }
  },
})
